package nodes;

import compiler.Compiler;
import compiler.SymbolTable;

import descriptors.AbstractDescr;

public class RepeatNode extends StatementNode {

	private ExpressionNode cond;
	private ListNode<StatementNode> statementSequence;
	
	public RepeatNode(ListNode<StatementNode> statementSequence,ExpressionNode cond,int line, int column){
		super(line,column);
		this.cond=cond;
		this.statementSequence=statementSequence;
	}
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public AbstractDescr compile(
			SymbolTable symbolTable, Compiler compiler) {
		int startLabel=compiler.newLabel();
		compiler.write("LABEL, "+startLabel);
		statementSequence.compile(symbolTable, compiler);
		cond.compile(symbolTable, compiler);
		compiler.write("BF, "+startLabel);
		return null;
	}

	@Override
	public void print() {
		trace("RepeatNode");
		statementSequence.print();
		trace("Until");
		cond.print();
		unindent();
		unindent();
	}

}
